<crm-main-nav  nav-c="main" page-title="公司商机"></crm-main-nav>
  <!-- 面包屑 -->
<div class="container">
  <ol class="breadcrumb">
    <li>CRM系统</li>
    <li>商机管理</li>
    <li class="active">商机详情</li>
  </ol>
</div>
  <!-- 内容 -->
<div ng-controller="mainMainKhxxyControler">
  <crm-panel title="添加事项">
    <form class="form-horizontal" role="form" ng-submit="addNoticeForm()">
      <div class="form-group">
        <label class="col-sm-1 control-label">事项类型：</label>
        <div class="col-sm-1">
          <select name="type" ng-model="noticeData.type" required>
            <option value="">--请选择--</option>
            <option value="沟通提醒" >--沟通提醒--</option>
            <option value="其他提醒" >--其他提醒--</option>
          </select>
        </div>
        <label class="col-sm-1 control-label">商机ID：</label>
        <div class="col-sm-1">
          <input type="text" class="form-control" ng-model="currentData.id" readonly>
        </div>  
        <label class="col-sm-1 control-label">提醒日期：</label>
        <date-input class="col-sm-1"  get-date="noticeData.reminder_date" style-date="YYYY-MM-DD" required></date-input>
        <label class="col-sm-1 control-label">备注内容：</label>
        <div class="col-sm-1">
          <input type="text" class="form-control" name="remark" ng-model="noticeData.remark" required>
        </div>
        <label class="col-sm-1 control-label">是否提醒：</label>
        <div class="col-sm-1">
          <select name="remind" ng-model="noticeData.remind" required>
            <option value="">--请选择--</option>
            <option value="1">是</option>
            <option value="0">否</option>
          </select>
        </div>
        <label class="col-sm-1 control-label">状态：</label>
        <div class="col-sm-1">
          <select name="state" ng-model="noticeData.state" required>
            <option value="">--请选择--</option>
            <option value="1">完成</option>
            <option value="0">未完成</option>
          </select>
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-offset-11 col-sm-1">
          <button type="submit" class="btn btn-primary">添加</button>
        </div>
      </div>
    </form>
  </crm-panel>
    <!-- 搜索框结束 --> 
  <crm-panel title="商机基本信息 - 客户姓名：{{currentData.name}} - 商机id：{{currentData.id}}">
    <form class="form-horizontal search-form" role="form" ng-submit="customerForm()">
      <div class="form-group" ng-if="business_type>=3">
        <label class="col-sm-1 control-label">分公司：</label>
        <div class="col-sm-1">
          <company-select current-id="currentData.branch_company_id"></company-select>
        </div>
        <label class="col-sm-1 control-label">咨询师：</label>
        <div class="col-sm-1">
          <user-select current-id="currentData.consultant_id" company-id="{{currentData.branch_company_id}}"></user-select>
        </div>
        <label class="col-sm-1 control-label">渠道经理：</label>
        <div class="col-sm-1">
          <user-select current-id="currentData.channel_manager_id" company-id="{{currentData.branch_company_id}}"></user-select>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label">订单号：</label>
        <div class="col-sm-1">
          <input type="text" class="form-control" name="order_id" ng-model="currentData.order_id">
        </div>
        <label class="col-sm-1 control-label">意向课程：</label>
        <div class="col-sm-1">
          <select name="training" class="form-control" ng-model="currentData.training">
            <option value="">--请选择--</option>
            <option value="WEB">WEB</option>
            <option value="UI">UI</option>
            <option value="JAVA">JAVA</option>
          </select>
        </div>
        <label class="col-sm-1 control-label">商机状态：</label>
        <div class="col-sm-1">
          <label class="control-label"><input type="radio" ng-value="0" ng-model="business_status" ng-click="changeBusinessStatus()">
    有效</label>
        </div>
        <div class="col-sm-1">
          <label class="control-label"><input type="radio" ng-value="1" ng-model="business_status" ng-click="changeBusinessStatus()">未来商机</label>
        </div>
          <date-input class="col-sm-2" ng-show="business_status==1" style-date="YYYY-MM-DD" get-date="currentData.future_business_time" ></date-input>
      </div>
      <div class="form-group">
        <info-source dependents="currentData.info_source"></info-source>
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label">手机号：</label>
        <div class="col-sm-2">
          <input type="text" class="form-control" ng-model="currentData.phone">
        </div>
      </div>
      <div class="alert alert-warning" role="alert">
        *提示：来源为社招的商机请按照 邀约登记>上门登记>签约登记>报到登记顺序进行操作；来源为校招的商机可直接进行签约登记操作;签约后需要在财务系统添加收款记录并确认收款后，该商机才算作是”已成交“
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label">邀约登记：</label>
        <div class="col-sm-3">
          <button type="button" class="btn btn-default" ng-if="currentData.invite==0" data-toggle="modal" data-target="#myModal">邀约登记</button>
          <label class="control-label text-l" ng-if="currentData.invite==1">{{currentData.invite_time | date : 'yyyy-MM-dd HH:mm'}}</label>
        </div>
        <div ng-if="currentData.invite==1">
          <label class="col-sm-1 control-label">上门登记</label>
          <div class="col-sm-3">
            <button type="button" class="btn btn-default" data-toggle="modal" ng-if="currentData.invite==1&&currentData.visit==0" data-target="#myModal2">上门登记</button>
            <label class="control-label text-l" ng-if="currentData.visit==1">{{currentData.visit_time | date : 'yyyy-MM-dd HH:mm'}}</label>
          </div>
        </div>
        <div ng-if="currentData.visit==1">
          <label class="col-sm-1 control-label">二次上门：</label>
            <date-input class="col-sm-2" get-date="currentData.second_visit_time" style-date="YYYY-MM-DD HH:mm:ss" ></date-input>
        </div>
      </div>
      <div class="form-group">
        <div ng-if="currentData.visit==1">
          <label class="col-sm-1 control-label">签约登记：</label>
          <div class="col-sm-3">
            <button type="button" class="btn btn-default" ng-if="currentData.sign==0&&currentData.visit==1" data-toggle="modal" data-target="#myModal3">签约登记</button>
            <label class="control-label text-l" ng-if="currentData.sign==1">{{currentData.sign_time | date : 'yyyy-MM-dd HH:mm:ss'}}</label>
          </div>
        </div>
        <div ng-if="currentData.sign==1">
          <label class="col-sm-1 control-label">成交登记：</label>
          <div class="col-sm-3">
            <button type="button" class="btn btn-default" ng-if="currentData.deal==0&&currentData.sign==1" data-toggle="modal" data-target="#myModal4">成交登记</button>
            <label class="control-label text-l" ng-if="currentData.deal==1">{{currentData.deal_time | date : 'yyyy-MM-dd HH:mm:ss'}}</label>
          </div>
        </div>
        <div ng-if="currentData.deal==1">
          <label class="col-sm-1 control-label">报到登记：</label>
          <div class="col-sm-3">
            <button type="button" class="btn btn-default" ng-if="currentData.registration==0&&currentData.deal==1" data-toggle="modal" data-target="#myModal5">报到登记</button>
            <label class="control-label text-l" ng-if="currentData.registration==1">{{currentData.registration_time | date : 'yyyy-MM-dd HH:mm:ss'}}</label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label">失败登记：</label>
        <div class="col-sm-3">
          <button type="button" class="btn btn-default" ng-if="currentData.business_type!=4" data-toggle="modal" data-target="#myModal1">失败登记</button>
          <label class="control-label text-l" ng-if="currentData.business_type==4">{{currentData.failure_reason_time | date : 'yyyy-MM-dd HH:mm:ss'}}</label>
        </div>
      </div>
      <div class="submit-box">
        <button type="submit" class="btn btn-primary">保存商机信息</button>
      </div>
  </form>
    <h3 class="form-tltle">跟进记录</h3>
    <form class="form-horizontal search-form row" name="follow_records" role="form" ng-submit="addFollowRecords(follow_records.$valid)" novalidate>
      <div class="form-group">
        <label class="control-label col-sm-2">沟通方式：</label>
        <div class="col-sm-2">
          <select name="mode" class="form-control" ng-model="followRecords.communication_mode" required>
            <option value="">请选择</option>
            <option value="电话">电话</option>
            <option value="面谈">面谈</option>
            <option value="QQ">QQ</option>
            <option value="其他">其他</option>
            <option value="内部面议">内部面议</option>
          </select>
        </div>
        <label class="control-label col-sm-1">时间：</label>
        <date-input class="col-sm-2" get-date="followRecords.time" style-date="YYYY-MM-DD HH:mm" readonly></date-input>
        <label class="control-label col-sm-1">内容：</label>
        <div class="col-sm-3" ng-class="{'has-error':!follow_records.content.$valid && (!follow_records.$pristine || follow_records.$submitted)}" >
          <input type="text" class="form-control" name="content" ng-model="followRecords.follow_records" required>
        </div>
        <div class="col-sm-1">
          <button type="submit" class="btn btn-primary">添加</button>
        </div>
      </div>
    </form>
    <table class="table table-bordered">
      <thead>
        <tr>
          <th>沟通方式</th>
          <th>操作时间</th>
          <th>操作内容</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="v in currentData.follow_up_records track by $index">
          <td>{{v.communication_mode}}</td>
          <td>{{v.time}}</td>
          <td>{{v.follow_records}}</td>
        </tr>
      </tbody>
    </table>
  </crm-panel>
  <crm-panel title="客户资料">
    <h3 class="form-tltle">基本信息</h3>
    <form class="form-horizontal search-form" role="form" ng-submit="addMessage()">
      <ng-include src="'partials/layout/business_data_form.html'" ></ng-include>
      <div class="submit-box">
        <button type="submit" class="btn btn-primary">保存客户资料</button>
      </div>
    </form>
  </crm-panel>
  <crm-panel title="操作记录">
    <table class="table table-bordered">
      <thead>
        <tr>
          <th>操作时间</th>
          <th>操作人</th>
          <th>类型</th>
          <th>操作内容</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="v in followRecordsList track by $index">
          <td>{{v.time}}</td>
          <td>{{v.user_id}}</td>
          <td>{{v.type}}</td>
          <td>{{v.follow_records}}</td>
        </tr>
      </tbody>
    </table>
  </crm-panel>
  <!-- 邀约登记模态框 -->
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">邀约登记</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label">邀约的时间</label>
              <date-input class="col-sm-4" style-date="YYYY-MM-DD HH:mm:ss" get-date="currentData.invite_time"></date-input>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="inviteSubmit()">确定</button>
        </div>
      </div>
    </div>
  </div>
  <!-- 失败登记模态框 -->
  <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">失败登记</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label">失败登记原因</label>
              <div class="col-sm-6">
                <business-class-select current-class="currentData.failure_reason_id" required></business-class-select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">失败登记时间</label>
              <date-input class="col-sm-4" style-date="YYYY-MM-DD HH:mm:ss" get-date="currentData.failure_reason_time"></date-input> 
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="failureSubmit()">确定</button>
        </div>
      </div>
    </div>
  </div>
 <!--上门登记模态框 -->
  <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">上门登记</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label">上门登记时间</label>
              <date-input class="col-sm-4" style-date="YYYY-MM-DD HH:mm" get-date="currentData.visit_time"></date-input> 
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="visitSubmit()">确定</button>
        </div>
      </div>
    </div>
  </div>
<!--签约登记模态框 -->
  <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">签约登记</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label">签约的时间</label>
              <date-input class="col-sm-4" style-date="YYYY-MM-DD HH:mm:ss" get-date="currentData.sign_time"></date-input> 
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="signSubmit()">确定</button>
        </div>
      </div>
    </div>
  </div>
  <!--成交登记模态框 -->
  <div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">成交登记</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label">成交的时间</label>
              <date-input class="col-sm-4" style-date="YYYY-MM-DD HH:mm:ss" get-date="currentData.deal_time"></date-input> 
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="dealSubmit()">确定</button>
        </div>
      </div>
    </div>
  </div>
  <!--报到登记模态框 -->
  <div class="modal fade" id="myModal5" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">报到登记</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label">报到的时间</label>
              <date-input class="col-sm-4" style-date="YYYY-MM-DD HH:mm:ss" get-date="currentData.registration_time"></date-input>
            </div>
          </div>
        </div> 
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="registrationSubmit()">确定</button>
        </div>
      </div>
    </div>
  </div>
</div>